package com.example.mvvmkotlin.db.initdb

import android.content.Context
import android.database.sqlite.SQLiteDatabase.CursorFactory
import com.example.mvvmkotlin.db.DaoMaster
import com.example.mvvmkotlin.db.UserBeanDao
import org.greenrobot.greendao.database.Database

class UpgradeDevOpenHelper : DaoMaster.DevOpenHelper {
    constructor(context: Context?, name: String?) : super(context, name) {}
    constructor(context: Context?, name: String?, factory: CursorFactory?) : super(
        context,
        name,
        factory
    ) {
    }

    /**
     * 数据库升级
     */
    override fun onUpgrade(db: Database?, oldVersion: Int, newVersion: Int) {
        //需要进行数据迁移更新的实体类

        db?.let { DBMigrationHelper.migrate(it, UserBeanDao::class.java) }
    }
}